Repository navigation
fix(cli): authenticate self-update with GITHUB_TOKEN/GH_TOKEN and hint on rate limit - #127
Merged
Merged
Conversation
…t on rate limit self-update never passed an auth token to the self_update crate (its builder defaults to None and does not read the environment), so codegraph self-update had no way to lift the anonymous GitHub API rate limit and failed with an opaque HTTP 403. Resolve a token from GITHUB_TOKEN then GH_TOKEN (gh CLI convention) via an injectable env-getter, rejecting empty/whitespace values, and apply it to every Update builder. On any GitHub-API call failure, surface the underlying error and append an actionable hint showing the exact reauth command. Behavior is unchanged when no token is set (anonymous). CLI-only and additive; extraction and golden byte-stability are untouched.
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (75.80%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage. @@ Coverage Diff @@
## main #127 +/- ##
==========================================
- Coverage 95.65% 95.64% -0.02%
==========================================
Files 115 115
Lines 55279 55334 +55
==========================================
+ Hits 52876 52923 +47
- Misses 2403 2411 +8
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
codegraph self-updatenever passed an auth token to theself_updatecrate — its builder defaultsauth_token: Noneand does not read the environment — so there was no way to lift the anonymous GitHub API rate limit, andself-updatefailed with an opaque HTTP 403.This PR fixes two defects in
crates/codegraph-cli/src/main.rs(CLI-only, additive):GITHUB_TOKENthenGH_TOKEN(gh CLI convention) via an injectable env-getter, rejecting empty/whitespace values, and apply.auth_token()inside the sharedconfigureclosure so all threeUpdatebuilders (--check, no---tagprobe, and the finalupdate()) authenticate uniformly. Behavior is unchanged when no token is set (anonymous, exactly as before)..context(...)to.with_context(|| ...), preserving the underlyingself_updateerror and appending a hint with the exact reauth commandGITHUB_TOKEN=$(gh auth token) codegraph self-update.mainprints errors with{err:#}(full anyhow chain), so the hint is user-visible.New unit tests in
mod self_update_testscover token precedence, GH_TOKEN fallback, empty/whitespace rejection, none-set, trimming, and the hint string (injectable getter — no unsafeset_var).Verification
make cigreen locally (fmt + clippy + test + guardrail) via pre-push hookself_update_tests: 12 passed (5 pre-existing + 7 new)equivalence.rs): 10 passed — extraction untouched